<?php if (!empty($page_info['back_referer_url'])): ?>
    <input type="hidden" name="back_referer_url" value="{:$page_info['back_referer_url']}" />
<?php endif; ?>

<?php foreach ($fields as $field => $vo): ?>
    <?php $value = emptyDef($vo['value'],$data[$field],'isset'); ?>
    <?php if ($vo['type'] == 'text'): ?>

    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <input class="form-control" type="text" id="{:$field}" name="{:$field}" placeholder="{:$vo['placeholder']}" value="{:$value}" />
    </div>
    <?php elseif (in_array($vo['type'], ['select1','select1_1'])): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <select class="form-control" id="{:$field}" name="{:$field}">
                <?php if ($vo['type'] == 'select1_1'): ?>
                    <option value="">请选择</option>
                <?php endif; ?>
                <?php foreach ($vo['params'] as $param_k => $param_v): ?>
                    <option value="{:$param_k}" {:isset($value) && $param_k==$value?'selected':''}>{:$param_v}</option>
                <?php endforeach ?>
            </select>
    </div>
    <?php elseif (in_array($vo['type'], ['select2','select2_1'])): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <select class="js-select2 form-control" id="{:$field}" name="{:$field}">
                <?php if ($vo['type'] == 'select2_1'): ?>
                    <option value="">请选择</option>
                <?php endif; ?>
                <?php foreach ($vo['params'] as $param_k => $param_v): ?>
                    <option value="{:$param_k}" {:isset($value) && $param_k==$value?'selected':''}>{:$param_v}</option>
                <?php endforeach ?>
            </select>
    </div>
    <?php elseif ($vo['type'] == 'textarea'): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <textarea class="form-control" id="{:$field}" name="{:$field}" rows="4" placeholder="{:$vo['placeholder']}">{:$value}</textarea>
    </div> 
    <?php elseif ($vo['type'] == 'file'): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']}</label>
        <div>
            <div id="{:$field}" class="uploader_btn">选择文件</div>
            <span class="uploader_span">{:$value}</span>
            <input class="form-control" type="hidden" name="{:$field}" value="{:$value}" />
            <img src="__UPLOAD__/{:$value}" class="cch_thumbnail" />
        </div>
    </div>
    <?php elseif ($vo['type'] == 'ueditor'): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <textarea id="{:$field}" class="ueditor" name="{:$field}" placeholder="{:$vo['placeholder']}">{:$value}</textarea>
    </div>
    <?php elseif ($vo['type'] == 'files'): ?>
    <div class="form-group col-md-12">
        <label class="col-lg-2 control-label">{:$vo['name']}</label>
        <div class="col-md-6">
            <div id="{:$field}" class="uploader_btns">选择文件</div>
        </div>
        <div class="uploader_more_div">
            <label class="col-lg-2 control-label"></label>
            <div class="col-md-6">
                <?php if (!empty($value)): ?>
                    <?php $images = explode(',', $value); ?>
                    <?php foreach ($images as $image): ?>
                        <div class="item">
                            <p><img src="__UPLOAD__/{:$image}" class="cch_thumbnail"></p>
                            <input type="hidden" name="{:$field}[]" value="{:$image}" />
                            <button type="button" class="btn btn-xs btn-danger" onclick="uploader_del(this)">删除</button>
                        </div>
                    <?php endforeach ?>
                <?php endif ?>
            </div>
        </div>
    </div>
    <?php elseif ($vo['type'] == 'checkbox'): ?>
    <?php $checkbox_data = empty($value) && $value != '0'?[]:explode(',', $value); ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
            <?php foreach ($vo['params'] as $param_k => $param_v): ?>
                <label class="checkbox-inline" for="{:$field.'_'.$param_k}">
                    <input type="checkbox" id="{:$field.'_'.$param_k}" name="{:$field}[]" value="{:$param_k}" {:isset($value) && in_array($param_k,$checkbox_data)?'checked':''} /> {:$param_v}
                </label>
            <?php endforeach ?>
    </div>
    <?php elseif ($vo['type'] == 'tags'): ?>
  

    <div class="form-group col-md-12">
        <label for="tags">{:$vo['name']}</label>
        <div class="form-group col-md-12">
            <?php $cur_tags = explode(',', $data['tags']); ?>
            <?php foreach ($fields['tags']['params'] as $tag): ?>
                <button type="button" class="tags-btn btn btn-xs {:in_array($tag['name'],$cur_tags)?'btn-success':''}">{:$tag['name']}</button>
            <?php endforeach ?>
            <input class="form-control js-tags-input" type="text" id="tags" name="tags" value="{:$data['tags']}" />
        </div>
    </div>
    <?php elseif ($vo['type'] == 'datetime'): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <input class="js-datetimepicker form-control" autocomplete="off" id="{:$field}" name="{:$field}" placeholder="{:$vo['placeholder']}" value="{:timeDef($value,'','Y-m-d H:i')}" data-locale="zh-cn" data-format="YYYY-MM-DD HH:mm" data-side-by-side="true"/>
    </div>
    <?php elseif ($vo['type'] == 'date'): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <input class="js-datetimepicker form-control" autocomplete="off" id="{:$field}" name="{:$field}" placeholder="{:$vo['placeholder']}" value="{:timeDef($value,'','Y-m-d H:i')}" data-locale="zh-cn" data-format="YYYY-MM-DD" />
    </div>
    <?php elseif ($vo['type'] == 'time'): ?>
    <div class="form-group col-md-12">
        <label for="{:$field}">{:$vo['name']} {:in_array('required',$vo['valids'])?'<span class="text-orange">*</span>':''}</label>
        
            <input class="js-datetimepicker form-control" autocomplete="off" id="{:$field}" name="{:$field}" placeholder="{:$vo['placeholder']}" value="{:timeDef($value,'','H:i')}" data-locale="zh-cn" data-format="HH:mm"/>
    </div>
    <?php endif ?>
<?php endforeach ?>

<script type="text/javascript">
  var static_path = '__STATIC__';
  var upload_path = '__UPLOAD__';
  var upload_api_server = '{:url('base/upload')}';
  var upload_type = 'admin';
</script>